<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('待分派到下级M')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="post-form">
                <div class="select-list">
                    <ul>
                        <li>
                            工单编号：<input type="text" name="workFormNo"/>
                        </li>
                        <li>
                            派发单位：<input type="text" name="sdeptName"/>
                        </li>

                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm " id="toolbar" role="group">
            <a class="btn btn-success single disabled" onclick="dlSendToSon()">
                <i class="fa"></i> 处理
            </a>
            <a class="btn btn-danger single disabled" onclick="backTo()">
                <i class="fa"></i> 退回
            </a>
            <a class="btn btn-primary single disabled" onclick="recall('')">
                <i class="fa"></i> 撤回
            </a>
        </div>

        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:src="@{/common/js/common.js}"></script>
<script th:inline="javascript">
    var cmnTab = ctx + "system/cmnTab";
    var prefix = ctx + "system/mMailWF";
    var mInterior = ctx + "system/mInterior";
    $(function () {
        var options = {
            url: prefix + "/rCity/sendWaitListJson",
            sortName: "myPkVal",
            sortOrder: "desc",
            uniqueId: "myPkVal",
            updateUrl: prefix+"/cmnFile/dlSignS/{id}",
            modalName: "待分派到下级",
            fixedColumns: true,
            fixedNumber: 2,
            fixedRightNumber: 1,
            columns: [{
                checkbox: true
            },
                {field:'myPkVal',title:'pkid',visible:false},
                {field:'WfId',title:'WfId',visible:false},
                {field:'myMwfNO',title:'工单编号',align:'center'},
                {field:'SpareString',title:'信件来源',align:'center',sortable:true},
                {field:'myMwfTopic',title:'工单主题',align:'center',
                    formatter:function (value, row, index,field) {
                        return "<span style='cursor: pointer;' title='"+value+"'>"+value+"</span>"
                    },
                    cellStyle: cellEllipsis
                },
                {field: 'FmContent', title: '工单内容', align: 'center',formatter:function (value, row, index,field) {
                        return "<span style='cursor: pointer;' title='"+value+"'>"+value+"</span>"
                    },
                    cellStyle: cellEllipsis},
                {field:'SeqName',title:'交办次序',align:'center'},
                {field:'SortName',title:'性质',align:'center',sortable:true},
                {field:'DealName',title:'办理方式',align:'center',sortable:true},
                {field:'SDeptName',title:'派发单位',align:'center',sortable:true},
                {field:'bkLimit',title:'办理期限',align:'center'},
                {field:'acDate',title:'签收日期',align:'center'},
                {field:'acDesc',title:'备注',align:'center'},
                {field:'FlagString',title:'转办情况',align:'center',sortable:true},
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs" style="margin-right: 5px;" href="javascript:void(0)" onclick="dlSendToSon('+row.myPkVal+')"><i class="fa fa-send-o"></i>派发</a>');
                        actions.push('<a class="btn btn-primary btn-xs " href="javascript:void(0)" onclick="recall('+row.myPkVal+')" "><i class="fa fa-undo"></i>撤回</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    function backTo(){
        let row = $("#bootstrap-table").bootstrapTable('getSelections');
        var sendId = row[0].myPkVal;
        var url = prefix + "/cmnFile/dlBackS/"+sendId;
        $.modal.openTab('退回信件工单',url);
    }

    function dlSendToSon(sbId) {
        var row = $("#bootstrap-table").bootstrapTable('getSelections');
        if(!(sbId)){
            sbId = row[0].myPkVal;
        }
        var url = cmnTab + "/mwfCSendWait/"+sbId;
        var width = '85%';
        var height = '95%';
        var config = {
            id: 'dlSendToSon',
            title: '拟派下级部门',
            width: width,
            height: height,
            url: url,
            callBack: function(index, layero) {
                var iframeWin = layero.find('iframe')[0];
                iframeWin.contentWindow.document.getElementById('navFrame').contentWindow.submitHandler(index);
            }
        };
        $.modal.openOptions(config);
    }

    //撤回待分发到下级工单（后续由本部门处理）
    function recall(id){
        if (id === '') {
            let row = $("#bootstrap-table").bootstrapTable('getSelections');
            id = row[0].myPkVal;
        }
        var url = prefix + "/cmnFile/revokeSendSubM?sendId="+id;
        var title = "撤回待分发到下级工单";
        $.modal.openTab(title,url);
    }
</script>
</body>
</html>